<template>
  <div>
    <el-dialog
      title="用户列表"
      :visible.sync="dialogTableVisible"
      custom-class="el-dialog-s"
      append-to-body
    >
      <el-card class="box-card">
        <div class="clearfix">
          <div class="container">
            <el-form
              size="small"
              label-width="100px"
            >
              <el-form-item label="用户名称：" class="width100">
                <el-input
                  v-model="formData.userNmae"
                  placeholder="请输入用户名称"
                  class="selWidth"
                  size="small"
                  clearable
                >
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    size="small"
                    @click="seachList"
                  />
                </el-input>
              </el-form-item>
            </el-form>
            <div style="margin-left:16px"></div>
          </div>
        </div>
      </el-card>
      <el-table :data="userFrom">
        <el-table-column property="uid" label="id" align="center" width="100"></el-table-column>
        <el-table-column
          property="nickname"
          label="姓名"
          align="center"
        ></el-table-column>
        <el-table-column property="phone" label="电话" align="center"></el-table-column>
        <el-table-column fixed="right" label="操作" width="100px">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              class="mr10"
              @click="details(scope.row)"
              >确定</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="$parent.adduseri()"
          :current-page.sync="pagesize.page"
          :page-sizes="[20, 40, 60, 80]"
          :page-size="pagesize.limit"
          layout="total,sizes,prev, pager, next,jumper"
          :total="pagesize.total"
          style="text-align: right; padding-top:20px"
        >
        </el-pagination>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { userListApi } from "@/api/groggery";
export default {
  name: "groggeryBoss",
  props: ["userFrom", "pagesize"],
  data() {
    return {
      dialogTableVisible: false,
      ggNo: "",
      formData: {
        userNmae:"",
        phone: "",
        page: 1,
        limit: 15
      }
    };
  },

  methods: {
    // 搜索
    seachList() {
      userListApi(this.formData)
        .then(res => {
          console.log(res)
          this.$emit("finduser", res.list);
          this.formData.keywords = "";
        })
        .catch(() => {});
    },
    // 确定
    details(row) {
      this.$emit("useruid", row.uid, row.nickname);
      this.$message.success("添加成功");
      this.dialogTableVisible = false;
    },
    //分页
    handleSizeChange(val) {
      this.pagesize.limit = val;
    }
  }
};
</script>

<style lang="scss" scoped>
.Boss {
  width: 200px;
  height: 200px;
  background-color: aqua;
  .block {
    padding: 20px;
    text-align: right;
    width: 100%;
    background-color: #ffffff;
  }
}
</style>
